from selenium.webdriver.common.by import By

from common.utils import chromeDriver


class Home:
    url = ""
    driver = ""

    def __init__(self):
        self.url = "http://8.155.1.153:8081/home"
        self.driver = chromeDriver.driver()
        self.driver.get(self.url)

    #进行首页元素的检查
    def HomeCheckElement(self):
        #检查首页按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > aside > div > div:nth-child(1) > ul > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span.ant-pro-base-menu-item-text.ant-pro-base-menu-item-text-has-icon")
        #检查问卷是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(1) > div > div.ant-statistic-title")
        #检查考试是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(2) > div > div.ant-statistic-title")
        #检查我的考试按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div.ant-tabs-tab.ant-tabs-tab-active")
        #检查我的问卷按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(2)")
        #检查问卷记录按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(3)")
        #检查考试记录按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-16 > div > div > div > div.ant-tabs-nav > div.ant-tabs-nav-wrap > div > div:nth-child(4)")

        #添加屏幕截图
        chromeDriver.getScreenShot()